package com.sinping.qh.repository.mongo.user;

import com.sinping.qh.domain.user.UserLaboratory;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.List;

/**
 * 用户负责实验室/院系
 *
 * @author Tiansx
 * @create 2018-06-06 9:37
 **/
public interface UserLaboratoryRepository extends MongoRepository<UserLaboratory,String> {
    /**
     * 获取用户负责的院系
     * @param userId
     * @param type
     * @return
     */
    List<UserLaboratory>findAllByUserIdAndType(String userId,String type);
    List<UserLaboratory>findAllByUserIdAndTypeOrderByGmtCreatedDesc(String userId,String type);
    List<UserLaboratory>findAllByUserIdOrderByGmtCreatedDesc(String userId);
    List<UserLaboratory>findAllByUserIdAndTypeAndStatusOrderByGmtCreatedDesc(String userId,String type,String status);
    List<UserLaboratory>findAllByUserIdAndStatusOrderByGmtCreatedDesc(String userId,String status);
    UserLaboratory findByManagerLabIdAndUserIdAndType(String managerLabId,String userId,String type);
    List<UserLaboratory> findAllByManagerLabId(String managerLabId);
    List<UserLaboratory>findByManagerUnitIdAndStatus(String managerUnitId,String status);
    List<UserLaboratory>findByManagerLabIdAndTypeAndStatusOrderByGmtCreatedDesc(List<String> labIDList,String type,String status);
    /**
     * 通过用户id和负责的院系Id删除
     * @param userId
     * @param managerUnitId
     * @return
     */
    void deleteByUserIdAndManagerUnitIdAndType(String userId,String managerUnitId,String type);

    /**
     * 通过用户id和负责的实验室id删除
     * @param userId
     * @param managerLabId
     * @return
     */
    void deleteByUserIdAndManagerUnitIdAndManagerLabIdAndType(String userId,String unitId,String managerLabId,String type);

    /**
     * 通过用户id,院系Id负责的实验室id和负责类型查找
     * @param userId
     * @param managerLabId
     * @param type :0：负责院系 1：负责实验室
     * @return
     */

    UserLaboratory findByUserIdAndManagerUnitIdAndManagerLabIdAndType(String userId,String managerUnitId,String managerLabId,String type);

    /**
     * 通过用户id,院系Id负责类型查找
     * @param userId
     * @param managerUnitId
     * @param type
     * @return
     */
    UserLaboratory findByUserIdAndManagerUnitIdAndType(String userId,String managerUnitId,String type);

    List<UserLaboratory> findAllByUserId(String userId);
    /**
     * 通过楼宇id查找
     */
    List<UserLaboratory>findAllByLabBuildingId(String buildingId);
    /**
     * 通过单位id查找
     */
    List<UserLaboratory>findAllByManagerUnitId(String unitId);
    List<UserLaboratory>findAllByManagerUnitIdAndType(String unitId,String type);
    List<UserLaboratory>findAllByManagerLabIdAndType(String labId,String type);
    List<UserLaboratory> findAllByUserIdAndTypeOrderByLabBuildingNameAscManagerRoomNoAsc(String userId,String type);
}
